package com.stlm2.dems.entity.base;

import com.github.wxpay.sdk.WXPayConfig;
import com.stlm2.dems.entity.PayChannel;

import java.io.InputStream;

/**
 * Author：fuchunyu
 * Date：2017/12/7
 * Description：
 */
public class BasePayConfig implements WXPayConfig {

   /* id
            company_code
    pay_channel
            app_id
    rsa_private_key
            alipay_public_key
    key
            mch_id
    app_secret*/

   private Integer id;
   private String companyCode;
   private PayChannel payChannel;
   private String appId;
   private String rsaPrivateKey;
   private String alipayPublicKey;
   private String key;
   private String mchId;
   private String appSecret;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCompanyCode() {
        return companyCode;
    }

    public void setCompanyCode(String companyCode) {
        this.companyCode = companyCode;
    }

    public PayChannel getPayChannel() {
        return payChannel;
    }

    public void setPayChannel(PayChannel payChannel) {
        this.payChannel = payChannel;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getRsaPrivateKey() {
        return rsaPrivateKey;
    }

    public void setRsaPrivateKey(String rsaPrivateKey) {
        this.rsaPrivateKey = rsaPrivateKey;
    }

    public String getAlipayPublicKey() {
        return alipayPublicKey;
    }

    public void setAlipayPublicKey(String alipayPublicKey) {
        this.alipayPublicKey = alipayPublicKey;
    }

    @Override
    public String getAppID() {
        return appId;
    }

    @Override
    public String getMchID() {
        return mchId;
    }

    public String getKey() {
        return key;
    }

    @Override
    public InputStream getCertStream() {
        return null;
    }

    @Override
    public int getHttpConnectTimeoutMs() {
        return 8000;
    }

    @Override
    public int getHttpReadTimeoutMs() {
        return 10000;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getMchId() {
        return mchId;
    }

    public void setMchId(String mchId) {
        this.mchId = mchId;
    }

    public String getAppSecret() {
        return appSecret;
    }

    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }

    /**
     * 支付渠道
     * @return
     */
    public Integer getPayChannelValue(){
        return (payChannel != null) ? payChannel.getIntValue() : null;
    }

    public void setPayChannelValue(Integer v){
        if(v != null)
            payChannel = PayChannel.getByIntValue(v);
    }
}
